﻿#ifndef ADD_PICTURE_H
#define ADD_PICTURE_H

#include <QWidget>
#include <QMainWindow>
#include <QPainter>
#include <QPushButton>
#include <QDebug>
#include <QToolBar>
#include <QAction>
#include "PatternStore.h"
#include "mainwindow.h"
#pragma execution_character_set("utf-8")

namespace Ui {
class add_picture;
}

class add_picture : public QWidget
{
    Q_OBJECT

public:
    explicit add_picture(QWidget *parent = nullptr);

    void updacanvasPixmap(patternstore *all_store);   //旋转矩阵
    void get_picture();    //从图案库获取图案

    void mousePressEvent(QMouseEvent *);
    void mouseMoveEvent(QMouseEvent *);
    void mouseReleaseEvent(QMouseEvent *);
    void paintEvent(QPaintEvent *e);

    ~add_picture();

private slots:
    void on_rectButton_clicked();

    void on_ellipseButton_clicked();

    void on_saveButton_clicked();

    void on_tableWidget_itemSelectionChanged();

    void on_tableWidget_cellClicked(int row, int column);

    void on_lineButton_clicked();

    void on_curveButton_clicked();

private:
    Ui::add_picture *ui;

    QPixmap pix;
    QPixmap tmp_pix;
    QPoint lastPoint;
    QPoint endPoint;
    QPoint tmpoint;
    QPoint tmpoint1;

    int drawtype;//图形编号
    int drawing;  //0是结束，1是正在画，2是待机
    int flag1 = 0;  //0是默认是新建，1是选中，确认是否选中图案
    int cur_sel;   //获取鼠标选中的图案编号


    QPixmap m_pixmap;			// 弧形图像
    QString a_text;				// 弧形文本
    QPixmap m_canvas_pixmap;     //画布的图案
    patternstore *a_all_store;

    int m_radius;    //弧形半径
    int m_fontsize = 12;  //文本字体大小
    int m_angle;    //文本旋转角度
};

#endif // ADD_PICTURE_H
